import React, { Component } from 'react'
import { Table } from 'antd';
import { connect } from 'dva';

  const columns = [{
    title: 'Name',
    dataIndex: 'name',
    render: text => <a href="javascript:;">{text}</a>,
  }, {
    title: 'Age',
    dataIndex: 'age',
  }, {
    title: 'Address',
    dataIndex: 'address',
  }];
  
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
    },
    getCheckboxProps: record => ({
      disabled: record.name === '拖', // Column configuration not to be checked
      name: record.name,
    }),
  };
@connect(({ user ,loading}) => ({ 
  userList: user.list, fetchingUsers: loading.effects['user/fetch']
}))
export default class UserInfo extends Component {
    render() {
        const {
          userList,
          fetchingUsers
        } = this.props;
        console.log("渲染")
        console.log(userList)
        userList.map((value,index)=>{
          value.key = index
        })
        return (
            <div>
            <div onClick={()=>{
              const { dispatch } = this.props
      dispatch({
          type: 'user/fetch',
          payload: {username:"嘿嘿"}
      })
              }
            }>ttttttttt</div>
                <Table
                  loading = {fetchingUsers} 
                  rowSelection={rowSelection} 
                  columns={columns} 
                  dataSource={userList} />
            </div>
        )
    }
  //   componentDidMount(){
  //     const { dispatch } = this.props
  //     dispatch({
  //         type: 'user/fetch',
  //         payload: {key:"嘿嘿"}
  //     })
  // }
}
